#include "registerpage.h"
#include "ui_registerpage.h"

RegisterPage::RegisterPage(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::RegisterPage)
{
    ui->setupUi(this);
    userFile = new FileIO();
}

RegisterPage::~RegisterPage()
{
    delete ui;
}

void RegisterPage::on_registerButton_clicked()
{
    QString accout = ui->accountLine->text();
    QString password =  ui->passwordLine->text();
    if(userFile->checkAcount(accout))
    {
        QMessageBox::critical(this,"用户已存在","账号已被使用");
        return;
    }
    userFile->insertPassword(User(accout,password));
}

void RegisterPage::on_loginButton_clicked()
{
    emit toPage("login");
    emit destory();
}
